package cn.id68.www.http.callback;

import okhttp3.Call;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Administrator on 2017/3/20.
 */

public abstract class Callback<T> {


    public void onBefore(Request request,int id){

    }

    public void onAfter(int id){

    }

    public void intProgress(float progress,long totale,int id){

    }

    public boolean validateReponse(Response response,int id){
        return response.isSuccessful();
    }

    public abstract T parseNetworkResponse(Response response,int id) throws  Exception;

    public abstract void onError(Call call,Exception e,int id);

    public abstract void onResponse(T response,int id);

    public static Callback CALLBACK_DEFAULT = new Callback() {
        @Override
        public Object parseNetworkResponse(Response response, int id) throws Exception {
            return null;
        }

        @Override
        public void onError(Call call, Exception e, int id) {

        }

        @Override
        public void onResponse(Object response, int id) {

        }
    };


}
